
package com.loan.rebate.weixin.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.loan.rebate.common.controller.BaseController;
import com.loan.rebate.weixin.common.WeixinUtils;

/**
 * 微信消息处理类
 *
 * @author 朱国军
 * @since 1.0
 * @version 2016年7月30日 朱国军
 */
@Controller
public class WeiXinController extends BaseController {

    @RequestMapping(value = "/uncheck/weixin/checkSignature")
    @ResponseBody
    public String checkSignature(HttpServletRequest request) {
        // 微信加密签名
        String signature = request.getParameter("signature");
        // 时间戳
        String timestamp = request.getParameter("timestamp");
        // 随机数
        String nonce = request.getParameter("nonce");
        // 随机字符串1
        String echostr = request.getParameter("echostr");
        if (!WeixinUtils.checkSignature(signature, timestamp, nonce)) {
            echostr = null;
        }
        return echostr;
    }

}
